This is a note on replication files for the paper accepted at Journal of Political Economy Macroeconomics:
"Procyclical Leverage and Crisis Probability in a Macroeconomic Model of Bank Runs"
by Daisuke Ikeda and Hidehiko Matsumoto.

This note is written by the authors on June 27, 2025.

All program codes are written and executed on a Windows 11 computer.
Matlab and Fortran are used.
Fortran codes are written and executed using Microsoft Visual Studio and Intel Fortran "ifx".

***** Folder "numerical_solution"

    *** Folder "20201010_draft_version"

        *** Folder "linear_model"
            * It contains dynare codes to do the initial calibration.
            * "run_IRF.m" runs dynare code "model_mod" and plots IRFs.
            * "model_results.mat" contains the calibration results, which are used in the main solution codes.

        *** Folder "no_policy_3rd" 
        * "z_main.m" is the main code that solves the model using PEA.
          It runs a fotran-based file "f90_bankrun_pea.exe" which simulates the model.
          It then imports simulation results from the fortran code and updates the decision rules until they converge.
        * "f90_bankrun_pea.sln" ia a MS Visual Studio solution file.
          It reads a project file "f90_bankrun_pea.vfproj" and runs a fotran code "f90_bankrun_pea_main.f90".
          This fortran code imports decision rules from matlab, simulates the model and exports simulation results to matlab.
        * "z_simulate.m" imports the solved decision rules and simulates the model with stochastic shocks.
          Simulation results are saved in "no_policy_mat". This file is used for main analyses in the paper.
          It also computes the moments in Table 3.
        * "z_simulate_regress_credit_k.m" simulates the model and runs regressions in Section 4.2.
          It spits out the regression results in Table 2.
        * "z_stochss.m" simulates the model and computes values in the stochastic steady state in Table 3.
        * Codes starting with "f90_eeerror..." are fortran codes that compute Euler equation erros of the solution.
        * Codes starting with "f90_welfare..." are fortran codes that compute the welfare gain by the macroprudential
          tax on leverage.
        * There are two sub codes used by other codes:
          "fn_expmx.m" creates the matrix of exponents for the polynomial.
          "func_Rb.m" is the FOC w.r.t. leverage, which is used to solve for Rbar.

        *** Folder "policy_fix_rate_including_runs" 
        * "z_main.m" and codes starting with "f90_bankrun_pea..." are the main solution codes as above.
        * "policy_tau_5_always.mat" contains the solved decision rules and simulation results.
        * "z_stochss.m"simulates the model and computes values in the stochastic steady state in Table 3.
        * "z_simulate_moments.m" simulates the model and computes the moments in Table 3.
        * Codes starting with "f90_eeerror..." are fortran codes that compute Euler equation erros of the solution.
        * Codes starting with "f90_welfare..." are fortran codes that compute the welfare gain by the macroprudential

        *** Folder "policy_leverage_cap_including_runs" 
        * "z_main.m" and codes starting with "f90_bankrun_pea..." are the main solution codes as above.
        * "policy_threL_150.mat" contains the solved decision rules and simulation results.
        * "z_stochss.m"simulates the model and computes values in the stochastic steady state in Table 3.
        * Codes starting with "f90_eeerror..." are fortran codes that compute Euler equation erros of the solution.
        * Codes starting with "f90_welfare..." are fortran codes that compute the welfare gain by the macroprudential

        *** Folder "RBC_model"
        * "z_main.m" and codes starting with "f90_bankrun_pea..." are the main solution codes as above.
        * "rbc_mat" contains the solved decision rules and simulation results.

        * Banking crisis database by Laeven and Valencia
        The data for the banking crisis in Laeven and Valencia (2018) is downloaded from the website below:
        https://www.imf.org/en/Publications/WP/Issues/2018/09/14/Systemic-Banking-Crises-Revisited-46232

    *** Folder "20240523_adjust_chi..."
        * Each folder solves the model with different chi0 in Figure 11.
        * "z_main.m" and codes starting with "f90_bankrun_pea..." are the main solution codes as above.
        * "z_simulate.m" simulates the model and computes the bank run and crisis probabilities in Figure 11.
        * Simulation results are saved in "no_policy.mat".

    *** Two fortran codes "minpack_indx.f90" and "my_toolbox.f90" are sub files that are used in the main fortran codes.

***** Folder "figure_replication"

    *** Matlab files "fig@@_..." are codes that reproduce figures in the paper.
    *** Matlab data files "no_policy.mat","policy_tau_5_always.mat","policy_threL_150.mat", and "rbc_mat" are
        files that contain stochstic simulation results created in the other folder.
    *** To reproduce Panel (b) and (d) in Figure 7, matlab file "fig7_run_dynamics_banking.m" requires the data
        downloaded from the Bloomberg terminal . Download the data "XLF" from the Bloomberg terminal,
        quarterly from 2002/12/31 to 2024/9/30 in cells "b7:b95" and save it in an excel file "xlf.xlsx".
        Then run the code after "return" in line 146.
        
